
*APPENDIX N - POST-ELECTION DECREASE IN ACCURACY AMONG MAINSTREA AND NICHE PARTIES

***Niche Party versus Mainstream Party 

/*
1st measure : mainstream= socialist, social democrats, lib dems, christian dems, conservatives, all others niche

mainstream
03. socialist parties
04. social democratic parties
07. right liberal parties 
06. liberal parties 
18. social-liberal parties 
08. christian democratic parties 
09. conservative parties

niche: 
01. ecology parties 
02. communist parties 
17. single issue parties 
19. extreme left 
21. extreme nationalist
23. extreme right
25. communist-green
10. national parties 
22. nationalist left
11. agrarian parties 
13. regional parties 
12. ethnic parties 
14. independent parties 
16. religious parties 
26. orthodox-calvinist
05. left liberal parties 


gen niche1 = .
replace niche1 = 1 if IMD5011_==1 | IMD5011_==2 | IMD5011_==17 | IMD5011_==19 | IMD5011_==21 | IMD5011_==23 | IMD5011_==25 | IMD5011_==10 | IMD5011_==22 | IMD5011_==11 | IMD5011_==13 | IMD5011_==12 | IMD5011_==14 | IMD5011_==16 | IMD5011_==26 | IMD5011_==5
replace niche1 = 0 if IMD5011_==3 | IMD5011_==4 | IMD5011_==7 | IMD5011_==6 | IMD5011_==18 | IMD5011_8 | IMD5011_==9



2nd measure : mainstream= socialist, social democrats, lib dems, christian dems, conservatives, niche (a la Adams et al): communists, greens, far-right , all others excluded

mainstream
03. socialist parties
04. social democratic parties
07. right liberal parties 
06. liberal parties 
18. social-liberal parties 
08. christian democratic parties 
09. conservative parties

niche

01. ecology parties 
02. communist parties 
17. single issue parties 
23. extreme right
25. communist-green


*/


/*
the following categories are coded as niche party:
01. ecology parties 
02. communist parties 
17. single issue parties 
19. extreme left 
21. extreme nationalist
23. extreme right
25. communist-green

the following categories are coded as non niche party:
03. socialist parties
04. social democratic parties
05. left liberal parties 
06. liberal parties 
07. right liberal parties 
08. christian democratic parties 
09. conservative parties
10. national parties 
22. nationalist left
24. centrist
18. social-liberal parties 
11. agrarian parties 
13. regional parties 
12. ethnic parties 
14. independent parties 
16. religious parties 
26. orthodox-calvinist
*/


*green, communist/socialist and nationalist families


********	niche versus mainstream parties 


clear all	
cd "${data}"	
use "data1.dta", clear 

*keep parfam IMD5012_ IMD5000_ IMD5011_ 
*duplicates drop 
*drop if IMD5012_==.

*save "${data}/partylist.dta", replace 



gen niche1 = .
replace niche1 = 1 if parfam == 10 | parfam == 20 | parfam == 70 
replace niche1 = 0 if parfam == 30 | parfam == 40 | parfam== 50 | parfam == 60 | parfam ==80 | parfam == 90 | parfam ==95

gen niche2 = . // without agrarian, ethnic-regional and special issue parties in the mainstream category
replace niche2 = 1 if parfam == 10 | parfam == 20 | parfam == 70 
replace niche2 = 0 if parfam == 30 | parfam == 40 | parfam== 50 | parfam == 60  


gen daysafter_niche1 = daysafter if niche1==1
gen daysafter_nonniche1 = daysafter if niche1==0
gen daysafter_niche2 = daysafter if niche2==1
gen daysafter_nonniche2 = daysafter if niche2==0



* measure 1 
eststo m1_niche1: mixed c.IMD3007_ c.daysafter##c.IMD5012_ if niche1==1 || country_: || election_: || respondent: IMD5012_  
margins, dydx(IMD5012_) at(daysafter=(0(30)300)) post
marginsplot, plot1opts(color(gs5) lpattern(shortdash)) recast(line) recastci(rarea) level(95) yline(0, lpattern(solid)) ci1opts(color(gs10*.8%50)) addplot(hist daysafter_niche1, percent color(gs5%20) yaxis(2) ytitle("percent", size(3) axis(2)) yscale(range(0(5)25) axis(2) alt)) legend(off) ytitle("", size(2.5)) title("") xscale(range(0(100)300)) xlabel(0(100)300) 
graph save "${figures}/niche1.gph", replace
graph export "${figures}/niche1.png", replace
	
eststo m1_nonniche1:  mixed c.IMD3007_ c.daysafter##c.IMD5012_ if niche1==0 || country_: || election_: || respondent: IMD5012_  
margins, dydx(IMD5012_) at(daysafter=(0(30)300)) post
marginsplot, plot1opts(color(gs5) lpattern(shortdash)) recast(line) recastci(rarea) level(95) yline(0, lpattern(solid)) ci1opts(color(gs10*.8%50)) addplot(hist daysafter_nonniche1, percent color(gs5%20) yaxis(2) ytitle("percent", size(3) axis(2)) yscale(range(0(5)25) axis(2) alt)) legend(off) ytitle("", size(2.5)) title("") xscale(range(0(100)300)) xlabel(0(100)300) 
graph save "${figures}/nonniche1.gph", replace
graph export "${figures}/nonniche1.png", replace


* measure 2 

eststo m1_nonniche2: mixed c.IMD3007_ c.daysafter##c.IMD5012_ if niche2==0 || country_: || election_: || respondent: IMD5012_  
margins, dydx(IMD5012_) at(daysafter=(0(30)300)) post
marginsplot, plot1opts(color(gs5) lpattern(shortdash)) recast(line) recastci(rarea) level(95) yline(0, lpattern(solid)) ci1opts(color(gs10*.8%50)) addplot(hist daysafter_nonniche2, percent color(gs5%20) yaxis(2) ytitle("percent", size(3) axis(2)) yscale(range(0(5)25) axis(2) alt)) legend(off) ytitle("", size(2.5)) title("") xscale(range(0(100)300)) xlabel(0(100)300) 
graph save "${figures}/nonniche2.gph", replace
graph export "${figures}/nonniche2.png", replace



cd "${figures}"	
graph combine "niche1.gph" "nonniche1.gph" "nonniche2.gph", ycommon xcommon row(1) ysize(5) xsize(12)
graph save "${figures}/figureN1.gph", replace
graph export "${figures}/figureN1.png", replace

cd "${tables}"	
esttab m1_niche1 m1_nonniche1 m1_nonniche2 using tableN2.tex, replace ///
b(3) se(3) nogap transform(ln*: exp(2*@) 2*exp(2*@)) ///
label mlabels ("Model 1" "Model 2" "Model 3")


